﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using eJack.Utility.Entity;

namespace eJack.Mortgage.Tool
{
	/// <summary>
	/// Interaction logic for MortgageItemControl.xaml
	/// </summary>
	public partial class MortgageItemControl : UserControl
	{
		public MortgageItemControl()
		{
			InitializeComponent();
		}

		public eLanguage Lang { get; set; }

		public void SetData(iMonthMortgageData imt, eLanguage elang)
		{
			this.Lang = elang;

			this.txtMonth.Content = imt.Month;
			this.txtDate.Content = imt.LoanDate;
			this.txtPrincipalPay.Content = imt.MonthPrincipal.ToString("C");
			this.txtInterestPay.Content = imt.MonthInterest.ToString("C");
			this.txtBalance.Content = imt.Balance.ToString("C");
		}

		public void SetData(iYearMortgageData iyt, eLanguage elang)
		{
			this.Lang = elang;

			this.txtMonth.FontWeight = FontWeights.SemiBold;
			this.txtMonth.Content = string.Format("{0} {1}", (this.Lang == eLanguage.English ? "Year" : "年"), iyt.Year);

			this.txtPrincipalPay.FontWeight = FontWeights.SemiBold;
			this.txtPrincipalPay.Content = iyt.YearPrincipal.ToString("C");

			this.txtInterestPay.FontWeight = FontWeights.SemiBold;
			this.txtInterestPay.Content = iyt.YearInterest.ToString("C");

			this.txtBalance.FontWeight = FontWeights.SemiBold;
			this.txtBalance.Content = iyt.Balance.ToString("C");

			foreach (var item in x.Children)
			{
				x.Margin = new Thickness(0, 3, 0, 0);
				var sp = item as StackPanel;
				sp.Children.Insert(0, new Border()
				{
					BorderThickness = new Thickness(0.6),
					HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
					VerticalAlignment = System.Windows.VerticalAlignment.Top,
					BorderBrush = new SolidColorBrush(Colors.Purple),
					Margin = new Thickness(0, 0, 0, -10)
				});
			}

			//brBalance.Visibility = System.Windows.Visibility.Visible;
			//brDate.Visibility = System.Windows.Visibility.Visible;
			//brMonth.Visibility = System.Windows.Visibility.Visible;
			//brPrincipal.Visibility = System.Windows.Visibility.Visible;
			//brInerest.Visibility = System.Windows.Visibility.Visible;
		}
	}
}
